import httpFetch from 'share/httpFetch';
import errorMessage from "share/errorMessage";

export default {

  getConfigList(page, size, params) {
    return httpFetch.post(`/api/receipt/check/config/query?page=${page}&size=${size}`, params)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      });
  },

  saveConfig(params) {
    return httpFetch.post(`/api/receipt/check/config/save`, params)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      });
  },

  deleteConfig(id) {
    return httpFetch.delete(`/api/receipt/check/config/delete?configId=${id}`)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      });
  },

  getConfigDetail(id) {
    return httpFetch.get(`/api/receipt/check/config/detail?configId=${id}`)
  },

  getRuleList(params) {
    return httpFetch.get(`/api/receipt/check/config/item/query`, params)
  },

  saveRule(params) {
    return httpFetch.post(`/api/receipt/check/config/item/save`, params)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      });
  },

  deleteRule(id) {
    return httpFetch.delete(`/api/receipt/check/config/item/${id}`)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      });
  },

}
